package com.aynu.gulimall.member.web;

import com.alibaba.fastjson.JSON;
import com.aynu.common.utils.R;
import com.aynu.gulimall.member.feign.OrderFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;

/**
 * @author mj
 * @version 1.0
 * @date 2021/4/11 22:09
 */
@Controller
public class MemberWebController {

    @Autowired
    private OrderFeignService orderFeignService;

    @GetMapping("/memberOrder.html")
    public String memberOrderListPage(@RequestParam(defaultValue = "1")Integer pageNum,
                                      @RequestParam(defaultValue = "5") Integer pageSize,
                                      Model model, HttpServletRequest request){

        HashMap<String, Object> map = new HashMap<>();
        map.put("page",pageNum.toString());
        map.put("pageSize",pageSize);
        R r = orderFeignService.listWithItem(map);
        System.out.println(JSON.toJSONString(r));
        model.addAttribute("orders",r);

        return "orderList";
    }
}
